package com.spring_book.spring_book.controller;


import com.spring_book.spring_book.service.UserService;
import jakarta.servlet.http.HttpSession;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RequestMapping("/user")
@RestController
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/login")
    public Boolean login(String name, String password, HttpSession session){
        log.info("接收"+name+"  "+password);
        //1.校验参数
        //2.从数据库中校验账号和密码是否正确
        //3.如果正确,存储session,返回true
        Boolean result = userService.checkUserAndPassword(name,password,session);
        log.info("用户登录结果，name：{}，结果：{}",name,result);
        return result;
    }
}
